#include "tools.h"
#include <string.h>
#include <unistd.h>
std::string path::get_current_dir()
{
    std::string path;
    char szDir[512];
    int cnt = readlink("/proc/self/exe", szDir, 512);
    if (cnt < 0 || cnt >= 512)
    {
        return path;
    }
    for (int i = cnt; i >= 0; --i)
    {
        if (szDir[i] == '/')
        {
            szDir[i + 1] = '\0';
            break;
        }
    }
    path = szDir;
    return path;
}